<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>动态时钟生成器</title>
    <style>
        body {
            font-family: 'Segoe UI', sans-serif;
            padding: 30px;
            background-color: #f0f3f5;
            min-height: 100vh;
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
        }

        #timeContainer {
            margin-top: 25px;
        }

        button {
            padding: 12px 25px;
            background: #00a8ff;
            color: white;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-size: 16px;
            transition: all 0.3s;
            box-shadow: 0 3px 6px rgba(0,168,255,0.2);
        }

        button:hover {
            background: #0097e6;
            transform: translateY(-2px);
        }

        .time-input {
            margin: 15px 0;
            padding: 12px;
            width: 220px;
            border: 2px solid #dcdde1;
            border-radius: 6px;
            font-size: 16px;
            transition: border-color 0.3s;
            background: white;
            color: #2f3640;
        }

        .time-input:focus {
            border-color: #00a8ff;
            outline: none;
        }

        .timestamp {
            color: #718093;
            font-size: 14px;
            margin-left: 15px;
        }
    </style>
</head>
<body>
    <div class="container">
        <button onclick="addTimeStamp()">生成时间戳</button>
        <div id="timeContainer"></div>
    </div>

    <script>
        // 生成格式化的时间字符串
        function getFormattedTime() {
            const now = new Date();
            
            // 补零函数
            const padZero = num => num.toString().padStart(2, '0');
            
            return `${now.getFullYear()}-${
                padZero(now.getMonth() + 1)}-${
                padZero(now.getDate())} ${
                padZero(now.getHours())}:${
                padZero(now.getMinutes())}:${
                padZero(now.getSeconds())}`;
        }

        // 添加时间输入框
        function addTimeStamp() {
            const container = document.getElementById('timeContainer');
            
            // 创建新输入框
            const newInput = document.createElement('input');
            newInput.type = 'text';
            newInput.className = 'time-input';
            newInput.value = getFormattedTime();
            newInput.readOnly = true;
            
            // 添加时间标签
            const timeLabel = document.createElement('span');
            timeLabel.className = 'timestamp';
            timeLabel.textContent = `生成时间：${new Date().toLocaleTimeString()}`;
            
            // 包装元素
            const wrapper = document.createElement('div');
            wrapper.appendChild(newInput);
            wrapper.appendChild(timeLabel);
            
            container.appendChild(wrapper);
        }
    </script>
</body>
</html>